package cn.xiuxius.embedded.model;

import com.fasterxml.jackson.annotation.JsonCreator;

public class Uart2PinFlashOptionType extends AbstractFlashOptionType<Uart2PinModeType> {
    public Uart2PinFlashOptionType(Uart2PinModeType value, String cmdValue, boolean isDefault) {
        super(value, cmdValue, isDefault);
    }

    public static final Uart2PinFlashOptionType DEFAULT = new Uart2PinFlashOptionType(Uart2PinModeType.DEFAULT, "default", true);
    @JsonCreator
    public static Uart2PinFlashOptionType from(Object val) {
        if (val instanceof String s) {
            if ("DEFAULT".equalsIgnoreCase(s)) {
                return DEFAULT;
            }
            if ("PASSTHROUGH".equalsIgnoreCase(s)) {
                return new Uart2PinFlashOptionType(Uart2PinModeType.PASSTHROUGH, Uart2PinModeType.PASSTHROUGH.getValue(), false);
            }
            if ("REMAP".equalsIgnoreCase(s)) {
                return new Uart2PinFlashOptionType(Uart2PinModeType.REMAP, Uart2PinModeType.REMAP.getValue(), false);
            }
        }
        throw new IllegalArgumentException("Unsupported Low&High Type input: " + val);
    }

    @Override
    public String getCmdValue() {
        return getValue().getValue();
    }


    @Override
    public boolean isDefault() {
        return DEFAULT.equals(this);
    }


}
